package string;

import java.util.Scanner;

/**
 * @Author: Miyako
 * @Date: 2024-07-12-11:31
 * @Description:通过matches方法正则表达式在字符串上的运用
 */
public class MatchesDemo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("输入一个邮箱用于判断格式");
            String input = sc.nextLine();
            String regex = "[A-za-z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-z]+)+";
            boolean match = input.matches(regex);
            if (match) {
                System.out.println("格式正确");
            } else {
                System.out.println("格式错误");
            }
        }

    }






}
